package com.example.DTO;

import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

public class FLTaskResultDTO {
    private String task_id;
    private ParametersDTO parameters;
    private ResultsDTO results;

    // 构造方法
    public FLTaskResultDTO() {}

    public FLTaskResultDTO(String task_id, ParametersDTO parameters, ResultsDTO results) {
        this.task_id = task_id;
        this.parameters = parameters;
        this.results = results;
    }

    // Getter 和 Setter
    public String getTask_id() { return task_id; }
    public void setTask_id(String task_id) { this.task_id = task_id; }
    public ParametersDTO getParameters() { return parameters; }
    public void setParameters(ParametersDTO parameters) { this.parameters = parameters; }
    public ResultsDTO getResults() { return results; }
    public void setResults(ResultsDTO results) { this.results = results; }

    // toString
    @Override
    public String toString() {
        return "FLTaskResultDTO{" +
                "task_id='" + task_id + '\'' +
                ", parameters=" + parameters +
                ", results=" + results +
                '}';
    }

    // equals 和 hashCode
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        FLTaskResultDTO that = (FLTaskResultDTO) o;
        return Objects.equals(task_id, that.task_id) &&
                Objects.equals(parameters, that.parameters) &&
                Objects.equals(results, that.results);
    }

    @Override
    public int hashCode() {
        return Objects.hash(task_id, parameters, results);
    }

    // ParametersDTO 内部类
    public static class ParametersDTO {
        private DatasetDTO dataset;

        // 构造方法
        public ParametersDTO() {}
        public ParametersDTO(DatasetDTO dataset) { this.dataset = dataset; }

        // Getter 和 Setter
        public DatasetDTO getDataset() { return dataset; }
        public void setDataset(DatasetDTO dataset) { this.dataset = dataset; }

        // toString
        @Override
        public String toString() {
            return "ParametersDTO{" + "dataset=" + dataset + '}';
        }

        // equals 和 hashCode
        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            ParametersDTO that = (ParametersDTO) o;
            return Objects.equals(dataset, that.dataset);
        }

        @Override
        public int hashCode() {
            return Objects.hash(dataset);
        }

        // DatasetDTO 内部类
        public static class DatasetDTO {
            private Integer batch_size;

            // 构造方法
            public DatasetDTO() {}
            public DatasetDTO(Integer batch_size) { this.batch_size = batch_size; }

            // Getter 和 Setter
            public Integer getBatch_size() { return batch_size; }
            public void setBatch_size(Integer batch_size) { this.batch_size = batch_size; }

            // toString
            @Override
            public String toString() {
                return "DatasetDTO{" + "batch_size=" + batch_size + '}';
            }

            // equals 和 hashCode
            @Override
            public boolean equals(Object o) {
                if (this == o) return true;
                if (o == null || getClass() != o.getClass()) return false;
                DatasetDTO that = (DatasetDTO) o;
                return Objects.equals(batch_size, that.batch_size);
            }

            @Override
            public int hashCode() {
                return Objects.hash(batch_size);
            }
        }
    }

    // ResultsDTO 内部类
    public static class ResultsDTO {
        private List<BigDecimal> train_acc;
        private List<BigDecimal> test_acc;
        private List<Integer> rounds;

        // 构造方法
        public ResultsDTO() {}
        public ResultsDTO(List<BigDecimal> train_acc, List<BigDecimal> test_acc, List<Integer> rounds) {
            this.train_acc = train_acc;
            this.test_acc = test_acc;
            this.rounds = rounds;
        }

        // Getter 和 Setter
        public List<BigDecimal> getTrain_acc() { return train_acc; }
        public void setTrain_acc(List<BigDecimal> train_acc) { this.train_acc = train_acc; }
        public List<BigDecimal> getTest_acc() { return test_acc; }
        public void setTest_acc(List<BigDecimal> test_acc) { this.test_acc = test_acc; }
        public List<Integer> getRounds() { return rounds; }
        public void setRounds(List<Integer> rounds) { this.rounds = rounds; }

        // toString
        @Override
        public String toString() {
            return "ResultsDTO{" +
                    "train_acc=" + train_acc +
                    ", test_acc=" + test_acc +
                    ", rounds=" + rounds +
                    '}';
        }

        // equals 和 hashCode
        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            ResultsDTO that = (ResultsDTO) o;
            return Objects.equals(train_acc, that.train_acc) &&
                    Objects.equals(test_acc, that.test_acc) &&
                    Objects.equals(rounds, that.rounds);
        }

        @Override
        public int hashCode() {
            return Objects.hash(train_acc, test_acc, rounds);
        }
    }
}